<ion-header>
  <ion-navbar color="headerColor">
    <ion-title>上班</ion-title>
  </ion-navbar>
</ion-header>


<ion-content padding class="bg-color">

  <div style="font-size: 1.2rem;text-align: center">
    <label>班长：</label>
    <span>{{personName}}</span>
    <label>班组日期</label>
    <input [(ngModel)]="bzDate" class="input-text" readonly (click)="getDate()">

    <label>班组选择</label>
    <input [(ngModel)]="bzSelect" type="radio" name="bzSelect" id="radioA" value="A" class="input-radio"><span id="spanA">A</span>
    <input [(ngModel)]="bzSelect" type="radio" name="bzSelect" id="radioB" value="B" class="input-radio"><span id="spanB">B</span>

    <label>上班时间</label>
    <input [(ngModel)]="workInTime" class="input-text-long" readonly (click)="getWorkTnTime()">

    <label>下班时间</label>
    <input [(ngModel)]="workOutTime" class="input-text-long" readonly (click)="getWorkOutTime()">
  </div>

  <div style="text-align: center;margin-top: 1%;">
    <button ion-button class="btn" (click)="setWork()">
      确认设置
    </button>
    <button ion-button class="btn" style="margin-left: 10%;" checked=false id="usbBun" (click)="usbScanner()">
      外设扫码
    </button>
  </div>
  <ion-input #scanText (change)="scanChange()" aria-readonly="true" id="scanTextId"
             style="width: 5rem;border: none;height: 0.6rem"></ion-input>
  <div>
    <div style="width: 10%;float: left;text-align: right;"><span
      style="font-size: 5rem;color: #f30d0d;"> {{startCount}}</span></div>
    <div style="font-size: 1.2rem;float: left;width: 90%;">
      <table  class="tabs_table">
        <tr>
           <td>
             <ion-item>
             <ion-select [(ngModel)]="defaultAttendanceType"  okText="确定" cancelText="取消" placeholder="考勤类型" (ngModelChange)="setDefaults()" >
               <ion-option *ngFor="let type of attendanceTypes" value="{{type.code}}">{{type.name}}</ion-option>
             </ion-select>
             </ion-item>
           </td>
          <td>
            <ion-item>
            <ion-select [(ngModel)]="defaultHandleType"  okText="确定" cancelText="取消" placeholder="工站" (ngModelChange)="defaultHandleTypeChange()" >
              <ion-option *ngFor="let type of handleTypes" value="{{type.code}}">{{type.name}}</ion-option>
            </ion-select>
            </ion-item>
          </td>

          <td>
            <ion-item>
              <ion-select [(ngModel)]="defaultProductSeries"  okText="确定" cancelText="取消" placeholder="产品系列" (ngModelChange)="defaultProductSeriesChange()" >
                <ion-option *ngFor="let type of defaultProductSeriess" value="{{type.CODE}}">{{type.NAME}}</ion-option>
              </ion-select>
            </ion-item>
          </td>

          <td>
            <ion-item>
              <ion-select [(ngModel)]="defaultProduct"  okText="确定" cancelText="取消" placeholder="产品系列" (ngModelChange)="setDefaults()" >
                <ion-option *ngFor="let type of defaultProductLists" value="{{type.PRODUCT_CODE}}">{{type.PRODUCT_NAME}}</ion-option>
              </ion-select>
            </ion-item>
          </td>

          <td>
            <ion-item>
              <button ion-button style="height: 2.8rem;width:6rem;font-size: 1.5rem" (click)="clearDefaults()">清除</button>
            </ion-item>
          </td>
        </tr>
      </table>


    </div>
  </div>

  <div style="margin-top: 1%" class="tableWrap">
    <table class="table-thead">
      <colgroup>
        <col width="8%">
        <col width="8%">
        <col width="9%">
        <col width="8%">
        <col width="10%">
        <col width="6%">
        <col width="8%">
        <col width="13%">
        <col width="13%">
        <col width="17%">
      </colgroup>
      <thead>
      <tr>
        <th>厂别</th>
        <th>工序</th>
        <th>工号</th>
        <th>姓名</th>
        <th>扫码时间</th>
        <th>考勤类型</th>
        <th>工站</th>
        <th>产品系列</th>
        <th>产品名称</th>
        <th>操作</th>
      </tr>
      </thead>
    </table>

    <div class="comTbody"  #tableScroll>
      <table class="table-tbody" style="border-top: 0;">
        <colgroup>
          <col width="8%">
          <col width="8%">
          <col width="9%">
          <col width="8%">
          <col width="10%">
          <col width="6%">
          <col width="8%">
          <col width="13%">
          <col width="13%">
          <col width="17%">
        </colgroup>
        <tbody id="tableBodys">
        <tr *ngFor="let item of dataList;let i=index" id="{{item.id}}">
          <td>{{item.branchFactoryName}}</td>
          <td>{{item.procedureName}}</td>
          <td>{{item.persionNum}}</td>
          <td>{{item.persionName}}</td>
          <td>{{item.cardStart}}</td>
          <td id="{{item.persionId}}Att">
              <div *ngFor="let type of attendanceTypes">
                <span *ngIf="type.code==item.attendanceType">{{type.name}}</span>
              </div>
          </td>
          <td id="{{item.persionId}}Handle">
            <div *ngFor="let type of handleTypes">
              <span *ngIf="type.code==item.handleType">{{type.name}}</span>
            </div>
          </td>
          <td id="{{item.persionId}}Series">
            {{item.seriesName}}
          </td>
          <td id="{{item.persionId}}Pro">
            {{item.proName}}
          </td>
          <!-- nowrap-->
          <td>
            <button ion-button style="height: 2.2rem;font-size: 1.2rem" *ngIf="item.isSource==0 && hasUpdating==false"
                    (click)="copyRow(item.persionId,item.persionNum,i)">增行
            </button>

            <button ion-button style="height: 2.2rem;font-size: 1.2rem"
                    *ngIf="hasUpdating==false && personId=='' && rowid==''"
                    (click)="updateRow(item.id,item.persionId,item.isSource,item.attendanceType,item.handleType,item.series,item.productId)">
              编辑
            </button>

            <button ion-button style="height: 2.2rem;font-size: 1.2rem"
                    *ngIf="hasUpdating==true && personId==item.persionId && rowid==item.id "
                    (click)="saveRow(item.id,item.persionId,item.isSource,i)">保存
            </button>

            <button ion-button style="height: 2.2rem;font-size: 1.2rem"
                    (click)="delRow(item.id,item.persionNum,item.persionId,item.isSource)">删除
            </button>
          </td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>
</ion-content>



